﻿
using Patterns4Net.Attributes.DesignPatterns;

namespace EnforcerExample.GUI
{
    using System;
    using System.Collections.Generic;
    using System.Linq;

    [Prototype]
    [Composite(typeof(IWidget))]
    public class WidgetComposition : IWidget, ICloneable
    {
        /* To make the implementation of Composite valid, uncomment the code. */
        //// private IEnumerable<IWidget> children;

        public WidgetComposition(IEnumerable<IWidget> children)
        {
            //// this.children = children;
        }

        public int Width
        {
            get
            {
                //// return this.children.Sum(x => x.Width);
                return 0;
            }
        }

        public int Height
        {
			[NotComposite]
            get
            {
                int result = 0;
                //// foreach (var widget in this.children)
                {
                    //// result += widget.Width;
                }

                return result;
            }
        }

        //// This attribute diasables the composite verification for this method
        [NotComposite]
        public object Clone()
        {
            return new object();
        }
    }
}
